/*
 * @Description: vuex
 * @Author: chenju
 * @Date: 2021-05-25 10:45:28
 * @LastEditors: chenju
 * @LastEditTime: 2023-02-17 10:43:54
 */
import { createStore, createLogger } from 'vuex'
import { store as app, AppStore, AppState } from '@/store/modules/app'
import { user, UserState } from '@/store/modules/user'
import { common, CommonState } from '@/commonModule/store/common'
export interface RootState {
  app: AppState
  user: UserState
  common: CommonState
}

export type Store = AppStore<Pick<RootState, 'app'>>

const debug = import.meta.env.NODE_ENV !== 'production'
const plugins = debug ? [createLogger()] : []

export const store = createStore({
  plugins,
  modules: {
    app,
    user,
    common
  }
})

export function useStore(): Store {
  return store as Store
}
